package com.visionork.android.twe;

import com.visionork.android.twe.model.DramaRepository;
import com.visionork.android.twe.model.RepositoryBase;
import com.visionork.android.twe.model.ShowRepository;

import android.app.Application;
import android.content.Context;

public class TWEApplication extends Application {
	private static Context context;
	private static RepositoryBase showRepository;
	private static RepositoryBase dramaRepository;

	public void onCreate() {
		TWEApplication.context = getApplicationContext();
	}

	public static Context getAppContext() {
		return context;
	}

	public static synchronized RepositoryBase getRepository(int id) {
		switch (id) {
		case RepositoryKey.ShowRepository:
			return getShowRepository();
		case RepositoryKey.DramaRepository:
			return getDramaRepository();
		}
		return null;
	}

	private static synchronized RepositoryBase getShowRepository() {
		if (showRepository == null) {
			showRepository = new ShowRepository();
		}
		return showRepository;
	}

	private static synchronized RepositoryBase getDramaRepository() {
		if (dramaRepository == null) {
			dramaRepository = new DramaRepository();
		}
		return dramaRepository;
	}
	
}
